package breadbox.pastry;

import java.io.Serializable;

/**
 * This interface should define all necessary fields of a message.
 * This will be used by the application to define it's own messages.
 * This will be wrapped by a lower level Pastry message that will
 * define system-specific fields. This message will most likely be 
 * serialized as is.
 * @author Brian
 *
 */

public class Message implements Serializable {
	private static final long serialVersionUID = 2909301676088840120L;
	public ID to, from;					    // ID's for destination and sender
	protected PastryMessageType type;		// Private, Pastry-specific type id
	public String key;						// Demux key for deserialization
	public byte[] data;						// Byte array containing serialized data
	
	/**
	 * Create a blank message
	 */
	public Message( ) {
		
	}
	
	/**
	 * Construct a new message from client to dataManagement
	 * @param to long (ID) to send message to
	 * @param key OperationType of current message
	 * @param data byte[], contents depend on OperationType
	 */
	public Message(long to, String key, byte[] data) {
		this.to = new LongID( to );
		this.key = key;
		this.data = data;
	}

}
